package cn.lanqiao.blog.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.lanqiao.blog.vo.CommentVO;
import cn.lanqiao.blog.service.CommentService;
import cn.lanqiao.blog.utils.Result;

@RestController
@RequestMapping("comment")
public class CommentController {

	@Autowired
	private CommentService commentService;
	@PostMapping("get")
	public Result getAllComment(Integer articleId) {
		List<CommentVO> comments = commentService.getCommentList(articleId);
		return Result.success(comments);
	}
	
	@PostMapping("save")
	public Result addComment(CommentVO comment) {
		int r = commentService.saveComment(comment);
		if(r>0) {
			
			return Result.success(200,"",null);
		}
		return Result.fail("您没有评论权限");
	}
}
